package cn.mobieteam.add.util;

import android.content.Context;
import android.content.SharedPreferences;
import cn.mobieteam.add.AppContext;
import cn.mobieteam.add.Constants;

public class SharePreferenceUtil {
	private SharedPreferences sp;
	private SharedPreferences.Editor editor;
	private Context context;

	public Context getContext() {
		return AppContext.get();
	}

	public SharePreferenceUtil() {
		context = getContext();
		sp = context.getSharedPreferences(Constants.STRING_SHARE_NAME,
				context.MODE_PRIVATE);
		editor = sp.edit();
	}

	// 用户名
	public void setUsername(String username) {
		editor.putString("username", username);
		editor.commit();
	}

	public String getUsername() {
		return sp.getString("username", "");
	}

	// 用户的密码
	public void setPasswd(String password) {
		editor.putString("password", password);
		editor.commit();
	}

	public String getPasswd() {
		return sp.getString("password", "");
	}

	// 电话
	public void setPhone(String phone) {
		editor.putString("phone", phone);
		editor.commit();
	}

	public String getPhone() {
		return sp.getString("phone", "");
	}

	// 头像
	public void setHead(String phone) {
		editor.putString("head", phone);
		editor.commit();
	}

	public String getHead() {
		return sp.getString("head", "");
	}

	// 是否在后台运行标记
	public void setIsStart(boolean isStart) {
		editor.putBoolean("isStart", isStart);
		editor.commit();
	}

	public boolean getIsStart() {
		return sp.getBoolean("isStart", false);
	}

	// 是否第一次运行本应用
	public void setIsFirst(boolean isFirst) {
		editor.putBoolean("isFirst", isFirst);
		editor.commit();
	}

	public boolean getisFirst() {
		return sp.getBoolean("isFirst", true);
	}
}
